// Copyright 叶湘 ( weixin:yexiang841, email:yexiang841@qq.com ), Shitouren Studio. All Rights Reserved.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerState.h"
#include "Q3D_CPPA_PlayerState.generated.h"

class UQ3D_CPPU_PawnState;

DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FQ3D_D_PawnState_Inc, UQ3D_CPPU_PawnState *, ptr_u_pawn_state_new);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FQ3D_D_PawnState_Dec, UQ3D_CPPU_PawnState *, ptr_u_pawn_state_old);

/**
 *
 */
UCLASS(Blueprintable, ClassGroup = (Q3D), meta = (Tooltip = "Q3D_PlayerState 基类(C++)"))
class Q3D_LIB_API AQ3D_CPPA_PlayerState : public APlayerState
{
	GENERATED_BODY()

public:
	AQ3D_CPPA_PlayerState();
	~AQ3D_CPPA_PlayerState();

public:
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Q3D_PlayerState, meta = (Tooltip = "必要时存储一个 Spectator 的 PawnState/Pawn，当 Player 需要漫游时使用"))
	UQ3D_CPPU_PawnState *Ptr_U_PawnState_Spectator = nullptr;

protected:
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Q3D_PlayerState, meta = (Tooltip = "存储属于自己 index 的 PawnState/Pawn，以 Name 为键"))
	TMap<FName, UQ3D_CPPU_PawnState *> Map_Name_To_Ptr_U_PawnState;

public:
	UFUNCTION(BlueprintCallable, Category = Q3D_PlayerState, meta = (Tooltip = "注册一个 PawnState/Pawn"))
	void Q3D_F_PawnState_Inc(UQ3D_CPPU_PawnState *ptr_u_pawn_state, UPARAM(DisplayName = "bool_success") bool &bool_success, UPARAM(DisplayName = "string_log") FString &string_log);

	UFUNCTION(BlueprintCallable, Category = Q3D_PlayerState, meta = (Tooltip = "注销一个 PawnState/Pawn，返回该 Player 的下一个可操控的 PawnState/Pawn(空指针表示没有下一个)"))
	void Q3D_F_PawnState_Dec(UQ3D_CPPU_PawnState *ptr_u_pawn_state, UPARAM(DisplayName = "bool_success") bool &bool_success, UPARAM(DisplayName = "string_log") FString &string_log, UPARAM(DisplayName = "ptr_u_pawn_state_next") UQ3D_CPPU_PawnState *&ptr_u_pawn_state_next);

	UFUNCTION(BlueprintPure, Category = Q3D_PlayerState, meta = (Tooltip = "根据 Pawn 查找是否在 PlayerState 中注册过，有的话返回对应的 PawnState，没有返回空指针"))
	void Q3D_F_PawnState_Find(APawn *ptr_pawn, UPARAM(DisplayName = "ptr_u_pawn_state") UQ3D_CPPU_PawnState *&ptr_u_pawn_state) const;

	UFUNCTION(BlueprintCallable, Category = Q3D_PlayerState, meta = (Tooltip = "设置一个 Spectator 的 PawnState/Pawn"))
	void Q3D_F_PawnState_Spectator_Set(UQ3D_CPPU_PawnState *ptr_u_pawn_state, UPARAM(DisplayName = "bool_success") bool &bool_success, UPARAM(DisplayName = "string_log") FString &string_log);

	UFUNCTION(BlueprintCallable, Category = Q3D_PlayerState, meta = (Tooltip = "删除 Spectator 的 PawnState/Pawn"))
	void Q3D_F_PawnState_Spectator_Unset(UPARAM(DisplayName = "bool_success") bool &bool_success, UPARAM(DisplayName = "string_log") FString &string_log);

public:
	UPROPERTY(BlueprintAssignable, Category = Q3D_PlayerState, meta = (Tooltip = "多播代理：新增 PawnState/Pawn"))
	FQ3D_D_PawnState_Inc Q3D_ED_PawnState_Inc;

	UPROPERTY(BlueprintAssignable, Category = Q3D_PlayerState, meta = (Tooltip = "多播代理：删除 PawnState/Pawn"))
	FQ3D_D_PawnState_Dec Q3D_ED_PawnState_Dec;
};
